/*
 * PayOrderInfoHolder.java
 * business
 *
 * Created by ChenTao on 2017/2/28.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.listview.viewholder;

import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yidiandao.business.R;
import com.yidiandao.business.data.bean.Order;
import com.yidiandao.business.ui.widget.listview.ViewHolder;

/**
 * 支付/购买的订单信息
 *
 * <p>Created by ChenTao(chentao7v@gmail.com) on 2017/2/21 16:31
 */
public class PayOrderInfoHolder extends ViewHolder {

    private LinearLayout consigneeLayout;
    private LinearLayout addressLayout;
    private TextView tvConsignee;
    private TextView tvOrderNumber;
    private TextView tvTime;
    private TextView tvPayWay;
    private TextView tvShippingWay;
    private TextView tvAddress;

    @Override
    protected void initView(View rootView) {
        tvConsignee = (TextView) rootView.findViewById(R.id.tv_consignee_name);
        tvOrderNumber = (TextView) rootView.findViewById(R.id.tv_order_number);
        tvTime = (TextView) rootView.findViewById(R.id.tv_time);
        tvPayWay = (TextView) rootView.findViewById(R.id.tv_pay_way);
        tvShippingWay = (TextView) rootView.findViewById(R.id.tv_shipping_way);
        tvAddress = (TextView) rootView.findViewById(R.id.tv_consignee_address);
        consigneeLayout = (LinearLayout) rootView.findViewById(R.id.consignee_layout);
        addressLayout = (LinearLayout) rootView.findViewById(R.id.address_layout);
    }

    @Override
    protected int getItemLayoutId() {
        return R.layout.item_pay_order_info;
    }

    public void refreshUI(Order order) {
        if (!TextUtils.isEmpty(order.getConsignee())) {
            consigneeLayout.setVisibility(View.VISIBLE);
            tvConsignee.setText(order.getConsignee());
        } else {
            consigneeLayout.setVisibility(View.GONE);
        }

        if (!TextUtils.isEmpty(order.getAddress())) {
            addressLayout.setVisibility(View.VISIBLE);
            tvAddress.setText(order.getAddress());
        } else {
            addressLayout.setVisibility(View.GONE);
        }

        tvOrderNumber.setText(order.getOrderSn());
        tvTime.setText(order.getAddTime());
        tvPayWay.setText(order.getPayName());
        tvShippingWay.setText(order.getShippingName());
    }
}
